package com.cdy.jxc_project.json;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

/**
 * @author qiu_tj
 * @version 1.0.0
 * @Description TODO
 * @Work hqyj_java_dept
 */
@Data
public class R {
    private String code;
    private Boolean success;
    private String message;
    private Map<String,Object> data = new HashMap<>();

//  私有构造方法
public R(){

    }
    public static R ok(){
        R r=new R();
        r.setCode(ResponseCode.success);
        r.setSuccess(true);
        return r;
    }
    public static R error(){
        R r=new R();
        r.setCode(ResponseCode.error);
        r.setSuccess(false);
        return r;
    }
    //提示文件
    public R message(String msg){
        this.setMessage(msg);
        return this;
    }
//  有数据
    public R data(Map<String,Object> result){
        this.setData(result);
        return this;
    }
//  第二种写法
    public R data(String key,Object value){
        this.data.put(key,value);
        return this;
    }
}
